import pandas as pd
import  numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn

###################seaborn.lmpolt回归图###################
#link=https://blog.csdn.net/qq_39949963/article/details/79362501
'''seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=None, height=5, 
aspect=1, markers='o', sharex=True, sharey=True, hue_order=None, col_order=None, row_order=None, 
legend=True, legend_out=True, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, 
ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, 
x_partial=None, y_partial=None, truncate=False, x_jitter=None, y_jitter=None, scatter_kws=None, line_kws=None, size=None)
'''

#url读取数据
url='https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv'
data=pd.read_csv('F:\pycharmProjects\data analysis\study_328\data.csv')
#print(data)
'''
#横坐标，纵坐标，数据，scatter_kws点的性质，line_kws线的性质
seaborn.lmplot('total_bill','tip',data,
               scatter_kws={'marker':',','color':'red'},
               line_kws={'linewidth':1,'color':'green'}
               ).savefig('picture2')
'''
#多图显示，row多图的横向显示，col多图的纵向显示，
#seaborn.lmplot(x='total_bill', y='tip', data=data,row='sex',col='smoker').savefig('picture1')

#col_wrap多图显示的列数控制,aspect长宽比
#seaborn.lmplot(x='total_bill', y='tip',data=data,col='day',col_wrap=3,aspect=1.5).savefig('picture1')

#多图显示，sharex、sharey共享xy轴，可选(row多图的横向显示，col多图的纵向显示)
#seaborn.lmplot(x='total_bill', y='tip', data=data,row='sex',col='smoker',sharex=True,sharey=False).savefig('picture1')

#单图显示，按hue='sex'分开,ci置信区间
seaborn.lmplot(x='total_bill',y='tip',data=data,hue='sex',palette='deep',ci=0.5).savefig('picture1')

#噪音点x_jitter=True，回归方程的次数order
#seaborn.lmplot(x='total_bill',y='tip',data=data,x_jitter=True,order=2).savefig('picture1')

#y去平均再做回归曲线
#seaborn.lmplot(x='size',y='tip',data=data,x_estimator=np.mean).savefig('picture1')